var t = require("../../@babel/runtime/helpers/interopRequireDefault").default, e = t(require("../../kta/index")), a = t(require("../../api/api_YQYL.js")), o = require("../../config/Links"), i = require("../../utils/YQYL"), n = t(require("../../api/auth.js"));

e.default.Page({
    data: {
        options: {},
        time: "",
        activity_info: {},
        succeedUser: [],
        shareUrl: "",
        poster: null,
        showPoster: !1,
        imgBaseUrl: o.imageBaseUrl.YQYL_new,
        postUtil: {
            handleSharePoster: function() {}
        },
        isLogin: !0,
        showCountDown: !1,
        countDownTimer: null,
        countDownTimer2: null,
        countDown: {
            d: "00",
            h: "00",
            m: "00",
            s: "00"
        },
        ts: 0,
        showNotice: !0,
        showToast: !1,
        isFinish: !1
    },
    onShareAppMessage: function() {
        return (0, i.handleShare)(this, "190");
    },
    onUnload: function() {
        clearTimeout(this.data.countDownTimer), clearInterval(this.data.countDownTimer2);
    },
    onLoad: function(t) {
        var e = this;
        this.data.options = t, (0, i.initPage)(this, t).then(function(t) {
            e.data.ts = t.end_time - t.now, e.setData({
                countDown: (0, i.formatTimeStamp)(e.data.ts)
            }), t.first_enter_flag && setTimeout(function() {
                e.handleCloseModal();
            }, 1e4), e.data.countDownTimer2 = setInterval(function() {
                e.data.ts -= 1e3, e.setData({
                    countDown: (0, i.formatTimeStamp)(e.data.ts)
                });
            }, 1e3);
        }), a.default.getSucceedUser().then(function(t) {
            e.setData({
                succeedUser: t.successRecordList
            });
        });
    },
    onChange: function(t) {
        this.setData({
            timeData: t.detail
        });
    },
    bindgetphonenumber: function(t) {
        var e = this;
        t.detail.iv && t.detail.encryptedData && n.default.auth({
            source: 2,
            encryptedData: t.detail.encryptedData,
            iv: t.detail.iv
        }).then(function() {
            (0, i.initPage)(e, e.data.options), a.default.getSucceedUser().then(function(t) {
                e.setData({
                    succeedUser: t.successRecordList
                });
            });
        }).catch(function() {
            wx.showToast({
                title: "切换手机号码失败，请重试",
                icon: "none"
            });
        });
    },
    handlePoster: function() {
        if (this.data.isFinish) return wx.showToast({
            title: "活动已结束，当前无法邀好友领奖励，更多优惠活动情关注“王卡助手”微信公众号。",
            icon: "none",
            duration: 2500
        }), !1;
        this.setData({
            showNotice: !1
        }), this.data.poster ? this.setData({
            showPoster: !0
        }) : this.data.postUtil.handleSharePoster();
    },
    handleShareText: function() {
        var t = this;
        if (this.data.isFinish) return wx.showToast({
            title: "活动已结束，当前无法邀好友领奖励，更多优惠活动情关注“王卡助手”微信公众号。",
            icon: "none",
            duration: 2500
        }), !1;
        this.setData({
            showNotice: !1,
            showToast: !0
        }), setTimeout(function() {
            t.setData({
                showToast: !1
            });
        }, 3e3), wx.setClipboardData({
            data: this.data.activity_info.invite_short_url
        });
    },
    toRecordPage: function() {
        (0, i.toRecordPage)();
    },
    toRulePage: function() {
        (0, i.toRulePage)();
    },
    toHomePage2Head: function() {
        (0, i.toHomePage2)(!1);
    },
    toHomePage2Modal: function() {
        (0, i.toHomePage2)(!0);
    },
    closePoster: function() {
        this.setData({
            showPoster: !1
        });
    },
    closeCountDownModal: function() {
        clearTimeout(this.data.countDownTimer), this.setData({
            showCountDown: !1
        });
    },
    handleCloseModal: function() {
        this.setData({
            showNotice: !1
        });
    }
});